<?php 
    $sql = "SELECT * FROM funcionario ORDER BY dt_inscricao DESC";
	$resultado = mysql_query($sql);
?>
<html>
<head>
	<title>JS</title>
        <style>
            #d1{
                position: absolute;
                top: 600px;
                height: 20px;
                width: 100%;
                background-color: #f00;
                color:#66ff66;
                display: none;
                text-align: center;
            }
            #corpo{
                margin: o auto;
                padding: 0;
                width: 960px;
                background-color: #f4f4f4;
                height: 600px;
            }
            #li{
                position: absolute;
                top: 5px;
                left: 80px;
            }
            #table1_filter label input{
                text-align: left;
                position: absolute;
                left: 580px;
                top: 4px;
            }
        </style>
	
        
        <script type="text/javascript" src="menu_assets/media/js/jquery.js"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="menu_assets/media/css/demo_page.css" > 
        <link rel="stylesheet" type="text/css" media="screen" href="menu_assets/media/css/demo_table.css" > 
        <script type="text/javascript" src="menu_assets/media/js/jquery.dataTables.min.js"></script>
	<script>
		$(function($){
                    $("#b1").click(function(){
                        $("#d1").slideDown(1000,function(){
                            $("#d1").slideUp(1000);
                        });
                    })
                });
        $(document).ready(function(){
            $('#table1').dataTable();

        });
        $(document).ready(function(){
            $("#a").click(function(){
                
                a = document.getElementById("a");
               
                if(a.src.match("Lightbulb_Off")){
                    a.src = "img/Lightbulb_On.png";
                }else{
                    a.src = "img/Lightbulb_Off.png";
                }
            }); 
        });
	</script>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
    
    <div id="corpo">
        <table cellspacing="0" cellpadding="0" border="0" class="display" id="table1">
            <thead>
                <tr>
                    <th>Matricula</th>
                    <th>Nome</th>
                    <th>Função</th>
                    <th>Data de Inscrição</th>
                    <td>Opções</td>
                </tr> 
            </thead>
            <tbody>

                <?php 	while($arrayResult = mysql_fetch_array($resultado)): ?>	
                        <?php if ($arrayResult['ativo'] == "1"): //caso o funcionario seja ativo! ?> 

                        <tr >
                                <td><?php echo $arrayResult['matricula']; ?></td>
                                <td><?php echo $arrayResult['no_funcionario']; ?></td>
                                <td><?php 
                                $sqlfun = "SELECT * FROM funcao";
                                $resultFun = mysql_query($sqlfun);
                                $arRefun = mysql_fetch_assoc($resultFun);
                                do{
                                if($arRefun['idfuncao'] == $arrayResult['idfuncao']){
                                           echo $arRefun['descricaofunc'];
                                        }
                                }while($arRefun = mysql_fetch_assoc($resultFun))?></td>
                                <td><?php 
                                                $data = $arrayResult['dt_inscricao'];
                                                $dataformatada = new DateTime($data);
                                                $date = $dataformatada->format('d/m/Y');
                                                $time = $dataformatada->format('H:i:s');
                                                echo $date." &nbsp".$time;
                                                //echo $arrayResult['dt_inscricao'];
                                                ?></td>
                                <td>
                                        <a href="index.php?page=funcionario/editarfuncionario.php&id=<?php echo $arrayResult['matricula']?>">
                                                  <img src="imagens/pen2.png" height="32" width="32"/>
                                        </a> &nbsp &nbsp	
                                        <a href="#" onClick='excluir(<?php echo $arrayResult['matricula']; ?>)'>
                                                  <img src="imagens/exc.png" height="32" width="32" />
                                        </a>	
                                </td>
                        </tr>

                        <?php endif ?>
                <?php endwhile; ?>

                
              
            </tbody>
        </table>
    </div><br>
</body>
</html>